package org.clockworkmages.games.anno1186.scripting.tools;

import org.clockworkmages.games.anno1186.model.effect.Effect;

public class EffectBuilder implements BuilderWrapper {

	private ScriptBuilder effectScriptBuilder;

	private ScriptBuilder conditionScriptBuilder;

	private EffectBuilder() {
		this.effectScriptBuilder = new ScriptBuilder(this);
		this.conditionScriptBuilder = new ScriptBuilder(this);
	}

	public static ScriptBuilder NEW() {
		return new EffectBuilder().getEffectScriptBuilder();
	}

	public static MeScriptBuilder me() {
		return new EffectBuilder().getEffectScriptBuilder().me();
	}

	public ScriptBuilder getEffectScriptBuilder() {
		return effectScriptBuilder;
	}

	public ScriptBuilder iff() {
		return conditionScriptBuilder;
	}

	public void then(String s) {
		throw new UnsupportedOperationException();
	}

	public void elsee(String s) {
		throw new UnsupportedOperationException();
	}

	public ScriptBuilder elseIf() {
		throw new UnsupportedOperationException();
	}

	public Effect compile() {
		String sEffect = effectScriptBuilder.toString();
		String sCondition = conditionScriptBuilder.toString();
		Effect effect;
		if (sCondition.length() > 0) {
			effect = new Effect(sEffect, sCondition);
		} else {
			effect = new Effect(sEffect);
		}
		return effect;
	}

}
